package modelo.zonariego;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import modelo.poligonal.Poligonal;
import modelo.regionRiego.RegionRiego;

@Entity
@Table(name="zona_riego")
public class ZonaRiego {
	private int id;
	private String nombre;
	private List<Poligonal> listaPoligonal;
	private RegionRiego regionRiego;
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getNombre() {
		return nombre;
	}
	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	@OneToMany(mappedBy = "zonaRiego")
	@Cascade({CascadeType.ALL})
	public List<Poligonal> getListaPoligonal() {
		return listaPoligonal;
	}
	public void setListaPoligonal(List<Poligonal> listaPoligonal) {
		this.listaPoligonal = listaPoligonal;
	}
	public void inicializarListaPoligonal(){
		listaPoligonal = new ArrayList<Poligonal>();
	}
	public void agregarPoligonal(Poligonal poligonal){
		listaPoligonal.add(poligonal);
	}
	@ManyToOne
	public RegionRiego getRegionRiego() {
		return regionRiego;
	}
	public void setRegionRiego(RegionRiego regionRiego) {
		this.regionRiego = regionRiego;
	}

	
}
